package com.eight.lesson3;

import java.io.BufferedReader;
import java.io.IOException;

import com.eight.lesson2.Apple;

/**
  *  利用函数式接口来传递Lambda
  *  函数式接口定义且只定义一个抽象方法 
 * @author Administrator
 *
 */
public class BufferedReaderTest {

	public static void main(String[] args) throws IOException {
		
		String oneline = BufferedReaderUtils.processFile((BufferedReader br) -> br.readLine());
		System.out.println("打印一行：");
		System.out.println(oneline);
		
		String twoline = BufferedReaderUtils.processFile((BufferedReader br) -> br.readLine() + "\n" + br.readLine());
		System.out.println("打印两行：");
		System.out.println(twoline);
		
		Apple apple = new Apple(150, "red");
		int s = 200;
		Runnable runnable = () -> {
			apple.setWeight(200);
			System.out.println(apple.getWeight());
			System.out.println(s);
		};
		apple.setWeight(300);
		Thread t = new Thread(runnable);
		t.start();
	}

}
